home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Source / Layout2.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  4.9 KB  |  243 lines

  1. #include <clib/extras/layoutgt_protos.h>
  2. #include <clib/extras_protos.h>
  3. #include <extras/layoutgt.h>
  4.  
  5. union Decode
  6. {
  7.   ULONG Long;
  8.   struct
  9.   {
  10.     BYTE Type, Code;
  11.     WORD Word;
  12.   } Decode;
  13. };
  14.  
  15.  
  16. WORD LG_FigureLeftEdge(struct LG_Control *Con, ULONG Code, struct IBox *Bounds,struct lg_DimInfo *Data)
  17. {
  18.   struct LG_GadgetIndex *gi;
  19.   union Decode command;
  20.   WORD word,w,h,retval;
  21.   BYTE code;
  22.  
  23.   command.Long=Code;
  24.   word=command.Decode.Word;
  25.   code=command.Decode.Code;
  26.   
  27.   retval=word;
  28.   
  29. //  le =Bounds->Left;
  30. //  te =Bounds->Top;
  31.   w  =Bounds->Width;
  32.   h  =Bounds->Height ;
  33.   
  34.   switch(command.Decode.Type)
  35.   {
  36.     case 1:
  37.       switch(command.Decode.Code)
  38.       {
  39.         case 0: // LG_REL_RIGHT
  40.           retval=(w + word);
  41.           break;
  42.         case 4: // LG_REL_CELL_LEFTEDGE
  43.           if(Data)
  44.             if(Data->CellsHoriz)
  45.               retval=((word * Bounds->Width + Data->GapHoriz)/Data->CellsHoriz);
  46.           break;         
  47.       }
  48.       break;
  49.     case 2: // LG_REL_LEFTOF
  50.       if(gi=LG_GetGI(Con,word))
  51.       {
  52.         retval=(gi->gi_Rect.MinX+code);
  53.       }
  54.       break;
  55.     case 6: // LG_REL_RIGHTOF
  56.       if(gi=LG_GetGI(Con,word))
  57.       {
  58.         retval=(gi->gi_Rect.MaxX+code);
  59.       }
  60.       break;      
  61.   }
  62.   return(retval);
  63. }
  64.  
  65.  
  66.  
  67. WORD LG_FigureWidth(struct LG_Control *Con, ULONG Code, struct IBox *Bounds, WORD LeftEdge, struct lg_DimInfo *Data)
  68. {
  69.   struct LG_GadgetIndex *gi;
  70.   union Decode command;
  71.   WORD word,w,h,retval;
  72.   BYTE code;
  73.  
  74.   command.Long=Code;
  75.   word=command.Decode.Word;
  76.   code=command.Decode.Code;
  77.   
  78.   retval=word;
  79.   
  80. //  le =Bounds->Left;
  81. //  te =Bounds->Top;
  82.   w  =Bounds->Width;
  83.   h  =Bounds->Height ;
  84.   
  85.   switch(command.Decode.Type)
  86.   {
  87.     case 1:
  88.       switch(command.Decode.Code)
  89.       {
  90.         case 1: // LG_REL_WIDTH
  91.           retval=(w + word);    
  92.           break;
  93.         case 6: // LG_REL_CELL_WIDTH
  94.           if(Data)
  95.             if(Data->CellsHoriz)
  96.               retval=((word * (Bounds->Width + Data->GapHoriz))/Data->CellsHoriz - Data->GapHoriz);
  97.           else
  98.             retval=(Bounds->Width);
  99.           break;          
  100.       }
  101.       break;
  102.     case 2: // LG_REL_LEFTOF
  103.       if(gi=LG_GetGI(Con,word))
  104.       {
  105.         retval=gi->gi_Rect.MinX + code - LeftEdge;
  106.       }
  107.       break;
  108.     case 4: // LG_REL_WIDTHOF
  109.       if(gi=LG_GetGI(Con,word))
  110.       {
  111.         retval=(gi->gi_Rect.MaxX-gi->gi_Rect.MinX + code);
  112.       }
  113.       break;      
  114.     case 6: // LG_REL_RIGHTOF
  115.       if(gi=LG_GetGI(Con,word))
  116.       {
  117.         retval=(gi->gi_Rect.MaxX+code) - LeftEdge;
  118.       }
  119.       break;      
  120.   }
  121.   return(retval);
  122. }
  123.  
  124.  
  125. WORD LG_FigureTopEdge(struct LG_Control *Con, ULONG Code, struct IBox *Bounds,struct lg_DimInfo *Data)
  126. {
  127.   struct LG_GadgetIndex *gi;
  128.   union Decode command;
  129.   WORD word,w,h,retval;
  130.   BYTE code;
  131.  
  132.   command.Long=Code;
  133.   word=command.Decode.Word;
  134.   code=command.Decode.Code;
  135.   
  136.   retval=word;
  137.   
  138. //  le =Bounds->Left;
  139. //  te =Bounds->Top;
  140.   w  =Bounds->Width;
  141.   h  =Bounds->Height ;
  142.   
  143.   switch(command.Decode.Type)
  144.   {
  145.     case 1:
  146.       switch(command.Decode.Code)
  147.       {
  148.         case 2: // LG_REL_BOTTOM
  149.           retval=(h + word);
  150.           break;
  151.         case 5: // LG_RELCELL_TOPEDGE
  152.           if(Data)
  153.             if(Data->CellsVert)
  154.               retval=((word * Bounds->Height+ Data->GapVert)/Data->CellsVert);
  155.           break;
  156.       }
  157.       break;
  158.     case 3: // LG_REL_TOPOF
  159.       if(gi=LG_GetGI(Con,word))
  160.       {
  161.         retval=(gi->gi_Rect.MinY+code);
  162.       }
  163.       break;
  164.     case 7: // LG_REL_BOTTOMOF
  165.       if(gi=LG_GetGI(Con,word))
  166.       {
  167.         retval=(gi->gi_Rect.MaxY+code);
  168.       }
  169.       break;      
  170.   }
  171.   return(retval);
  172. }
  173.  
  174.  
  175. WORD LG_FigureHeight(struct LG_Control *Con, ULONG Code, struct IBox *Bounds,WORD TopEdge, struct lg_DimInfo *Data)
  176. {
  177.   struct LG_GadgetIndex *gi;
  178.   union Decode command;
  179.   WORD word,w,h,retval;
  180.   BYTE code;
  181.  
  182.   command.Long=Code;
  183.   word=command.Decode.Word;
  184.   code=command.Decode.Code;
  185.   
  186.   retval=word;
  187.   
  188. //  le =Bounds->Left;
  189. //  te =Bounds->Top;
  190.   w  =Bounds->Width;
  191.   h  =Bounds->Height ;
  192.   
  193.   switch(command.Decode.Type)
  194.   {
  195.     case 1:
  196.       switch(command.Decode.Code)
  197.       {
  198.         case 3: // LG_REL_HEIGHT
  199.           retval=(h + word);    
  200.           break;
  201.         case 7: // LG_REL_CELL_HEIGHT
  202.           if(Data)
  203.             if(Data->CellsVert)
  204.               retval=((word * (Bounds->Height + Data->GapVert))/Data->CellsVert - Data->GapVert);
  205.             else
  206.               retval=(Bounds->Width);
  207.           break;          
  208.       }
  209.       break;
  210.     case 3: // LG_REL_TOPOF
  211.       if(gi=LG_GetGI(Con,word))
  212.       {
  213.         retval=(gi->gi_Rect.MinY+code) - TopEdge;
  214.       }
  215.       break;
  216.     case 5: // LG_REL_HEIGHTOF
  217.       if(gi=LG_GetGI(Con,word))
  218.       {
  219.         retval=(gi->gi_Rect.MaxY-gi->gi_Rect.MinY+code);
  220.       }
  221.       break;      
  222.     case 7: // LG_REL_BOTTOMOF
  223.       if(gi=LG_GetGI(Con,word))
  224.       {
  225.         retval=(gi->gi_Rect.MaxY+code) - TopEdge;
  226.       }
  227.       break;      
  228.   }
  229.   return(retval);
  230. }
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.